<template>
  <div>
    <base-list ref="baselist"
               :condition="condition"
               :datas.sync="data"
               :pageSearch="pageSearch">
      <el-row slot="search"
              class="title-header">
        <h4>验收修改处理页面</h4>
      </el-row>
      <el-form :inline="true"
               :model="condition"
               class="search-form"
               slot="search"
               ref="aList"
               label-width="100px">
        <el-row>
          <el-col :span="8"
                  class="search-width6">
            <el-form-item label="验收单号">
              <el-input v-model="condition['search_LIKE_checkAcceptNo']"
                        placeholder=""></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5"
                  class="search-width6">
            <el-form-item label="货主">
              <auto-search-name placeholder="请选择"
                                @selectId="v=>condition['search_EQ_cargoOwnerId']=v"
                                :name="form.cargoOwnerName"></auto-search-name>
            </el-form-item>
          </el-col>
          <el-col :span="7"
                  class="search-width6">
            <el-form-item label="车船号">
              <el-input type="text"
                        v-model="condition['search_LIKE_transhipNo']"
                        placeholder="请输入内容"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="7"
                  class="search-width6">
            <el-form-item label="品名">
              <el-select v-model="condition['search_EQ_cargoCode']"
                         placeholder="请选择"
                         clearable
                         filterable>
                <el-option v-for="item in cargoNameList"
                           :key="item.cargoCode"
                           :label="item.cargoName"
                           :value="item.cargoCode"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="5"
                  class="search-width6">
            <el-form-item label="材质">
              <auto-search-dic v-model="condition['search_EQ_material']"
                               @selectName="v=>condition['search_EQ_material']=v"
                               code="CARGO_CZ"></auto-search-dic>
            </el-form-item>
          </el-col>
          <el-col :span="5"
                  class="search-width6">
            <el-form-item label="生产厂家"
                          clearable>
              <auto-search-dic v-model="condition['search_EQ_madeBy']"
                               @selectName="v=>condition['search_EQ_madeBy']=v"
                               code="CARGO_SCZ"></auto-search-dic>
            </el-form-item>
          </el-col>
          <el-col :span="5"
                  class="search-width8">
            <el-form-item label="规格"
                          class="gg-input">
              <el-col :span="8">
                <auto-search-dic style="width: 100px;"
                                 @selectName="v=>condition['search_EQ_normOne']=v"
                                 code="CARGO_GGY"></auto-search-dic>
              </el-col>
              <el-col :span="8">
                <auto-search-dic style="width: 100px;"
                                 @selectName="v=>condition['search_EQ_normTwo']=v"
                                 code="CARGO_GGE"></auto-search-dic>
              </el-col>
              <el-col :span="8">
                <auto-search-dic style="width: 100px;"
                                 @selectName="v=>condition['search_EQ_normThree']=v"
                                 code="CARGO_GGS"></auto-search-dic>
              </el-col>
            </el-form-item>
          </el-col>
          <el-col :span="5"
                  class="search-width8">
            <el-form-item label="退回时间">
              <el-date-picker style="width:150px;"
                              v-model="condition['search_GTE_aduitTime']"
                              type="date"
                              placeholder="选择日期"
                              value-format="yyyy-MM-dd 00:00:00"> </el-date-picker> 至
              <el-date-picker style="width:150px;"
                              v-model="condition['search_LTE_aduitTime']"
                              type="date"
                              placeholder="选择日期"
                              value-format="yyyy-MM-dd 23:59:59"> </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-button type="primary"
                       icon="el-icon-search"
                       class="ml-100"
                       @click="loadData">查 询</el-button>
            <el-button formVisible="true"
                       icon="el-icon-refresh"
                       @click="resuleBtn('aList')">
              重置
            </el-button>
          </el-col>
        </el-row>
      </el-form>
      <el-table slot="list"
                :data="data"
                border
                stripe
                max-height="550">
        <el-table-column type="index"
                         label="序号"
                         width="50"
                         align="center"></el-table-column>
        <el-table-column prop="checkAcceptNo"
                         label="验收单号"
                         min-width="120"></el-table-column>
        <el-table-column prop="auditStatus"
                         label="状态"
                         min-width="100">
          <template slot-scope="scope">
            {{ scope.row.auditStatus | _filterInwayStatus}}
          </template>
        </el-table-column>
        <el-table-column prop="cargoOwnerName"
                         label="货主"
                         min-width="150"></el-table-column>
        <el-table-column prop="transhipNo"
                         label="车船号"
                         min-width="100"></el-table-column>
        <el-table-column prop="inWayName"
                         label="入库方式"
                         min-width="150"></el-table-column>
        <el-table-column prop="cargoName"
                         label="品名"
                         min-width="100"></el-table-column>
        <el-table-column prop="material"
                         label="材质"
                         min-width="120"></el-table-column>
        <el-table-column prop="normStr"
                         label="规格"
                         min-width="100"></el-table-column>
        <el-table-column prop="madeBy"
                         label="生产厂家"
                         min-width="120"></el-table-column>
        <el-table-column prop="checkAcceptNum"
                         label="验收件数"
                         min-width="120"></el-table-column>
        <el-table-column prop="checkAcceptWeight"
                         label="验收重量"
                         min-width="120"></el-table-column>
        <el-table-column prop="aduitMan"
                         label="退回人员"
                         min-width="100"></el-table-column>
        <el-table-column prop="aduitTime"
                         label="退回时间"
                         min-width="180"></el-table-column>
        <el-table-column label="操作"
                         align="center"
                         min-width="120"
                         fixed="right">
          <template slot-scope="scope">
            <el-button type="text"
                       size="small"
                       @click="handleDialogForm(scope.row,true)">修改</el-button>
            <!-- <el-button type="text"
                       class="danger"
                       size="small"
                       @click.stop="handleRemove(scope.row)">退回
            </el-button> -->
          </template>
        </el-table-column>
      </el-table>
    </base-list>
    <check-in-form ref="checkInForm"
                   @load="loadData"></check-in-form>
  </div>
</template>

<script>
import { getCargoNameList } from '@/api/things/accountPageList'
import { getAcceptanceInList } from '@/api/enter/acceptanceIn'
import autoSearchDic from '@/components/autocomplete/autoSearchDic'
import autoSearchName from '@/components/autocomplete/autoSearchName' //货主组件
import checkInForm from './checkInForm'

export default {
  name: 'acceptanceModifyCom',
  components: {
    autoSearchDic,
    autoSearchName,
    checkInForm
  },
  data() {
    return {
      form: this.clearForm(),
      pageSearch: getAcceptanceInList, // 分页查询api接口
      condition: { search_EQ_adiutStatus: 'D' },
      component: '',
      cargoNameList: [], //品名
      data: []
    }
  },
  mounted() {
    this.$nextTick(() => {
      this.loadData()
    })
    //获取品名
    getCargoNameList(this.$store.state.user.currentUser.org.id).then(res => {
      this.cargoNameList = res.data.aaData
    })
  },
  methods: {
    clearForm() {
      return {}
    },
    loadData() {
      getAcceptanceInList({search_EQ_adiutStatus: 'D'}).then(res => {
        console.log(res.data.aaData)
        this.data = res.data.aaData
      })
      // this.$refs.baselist.loadData()
    },
    handleDialogForm(item, bool) {
      if (bool) {
        console.log('修改',item)
        this.$refs.checkInForm.form = JSON.parse(JSON.stringify(item))
        this.$refs.checkInForm.isEdit = true
        this.$refs.checkInForm.dialogForm = true
      } else {
        this.$refs.checkInForm.dialogForm = true
      }
    },
    //删除
    handleRemove(item) {
      this.$confirm(`是否删除该数据?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          deleteCargo(item.id).then(res => {
            this.$message({
              type: 'success',
              message: `删除成功!`
            })
            this.loadData()
          })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          })
        })
    },
    //重置
    resuleBtn(aList) {
      this.$refs[aList].resetFields()
      this.condition = this.clearForm()
    }
  }
}
</script>
<style scoped>
